/*
 * @Author: Anan 
 * @Date: 2022-05-09 22:49:52 
 * @Last Modified by: Anan
 * @Last Modified time: 2022-05-11 21:49:01
 */



import { Effect, Reducer } from 'umi';
import { getProdTag } from '@/services'
import { IProdTag } from '@/types'

export interface ProdTagModelState {
  ProdTagList: IProdTag[];
}

export interface ProdTagModelType {
  namespace: 'prod-prodTag';
  state: ProdTagModelState;
  effects: {
    getProdTagList:Effect;
  };
  reducers: {
    save: Reducer<ProdTagModelState>;
  };
}

const ProdTagModel: ProdTagModelType = {
  namespace: 'prod-prodTag',
  state: {
    ProdTagList: [],
  },

  effects: {
    *getProdTagList({payload}, {call, put}){
      let result = yield call(getProdTag);
      
      console.log(result,'ProdTagList...');
      if (result.data){
        yield put({
          type: 'save',
          payload: {
            userList: result.data
          }
        })
      }
    },
  },
  reducers: {
    save(state, action) {
      return {
        ...state,
        ...action.payload,
      };
    },
  },
};

export default ProdTagModel;
